// *** LICENSE HEADER ***
// Filename: ./lightmanager.h
// This file is part of Nodewarz 0.1
// Nodewarz is a 3d OpenGL strategy game
// Copyright (C) 2007 CZestmyr
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// *** END LICENSE HEADER ***
#ifndef NODEWARS_LIGHTMANAGER_H
#define NODEWARS_LIGHTMANAGER_H

#include "light.h"
#include "gameboard.h"

class light;
class gameBoard;

//Struct used as a linked-list node for lights
struct lightNode {
    light* data;
    lightNode* next;
};

//Class storing the game light data and updating gameboard lightmap
class lightManager {
    public:
        lightManager();
        ~lightManager();

        //Set a new pointer to the gameboard object
        void SetGameBoardPointer(gameBoard* newBoard);

        //Add a light to the scene and return it's pointer
        light* AddLight(float r, float g, float b, float x, float y, float radius);
        //Remove the specified light from the linked-list
        void RemoveLight(light* l);
        //Remove a light at the specified coordinates from the linked-list
        void RemoveLight(float x, float y);
        //Remove all the game lights (delete the linked-list)
        void FlushLights();
        //Change the specified light's radius to a new one and recalculate the lightmap
        void UpdateLightRadius(light* l, float newRadius);

        //Return the light color at the given position
        void GetLightColorAt(float x, float y, float& r, float& g, float& b);
    private:
        //Linked-list of the lights
        lightNode* lightList;
        //Pointer to the gameboard
        gameBoard* theBoard;
};

#endif
